package com.example.tester.mq;

import com.example.tester.config.RabbitTopicConfig;
import com.example.tester.entity.User;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 *
 * 消息队列-消费者---用于接收MQ消息
 *
 *
 * @author lzh
 * @date 2019/9/11 - 11:23
 */
@Component
public class TopicReceiver {

    // queues是指要监听的队列的名字
    @RabbitListener(queues = RabbitTopicConfig.TOPIC_QUEUE1)
    public void receiveTopic1(User user) {
        System.out.println("【receiveTopic1监听到消息】" + user.toString());
    }
    @RabbitListener(queues = RabbitTopicConfig.TOPIC_QUEUE2)
    public void receiveTopic2(User user) {
        System.out.println("【receiveTopic2监听到消息】" + user.toString());
    }

}
